package com.zxx.pattern.iteratorPattern.iterator2;

import com.zxx.pattern.iteratorPattern.iterator2.old.MenuItem;

/**
 * 电影节目的迭代器
 *
 * @author zxx on 2021/4/8
 */
public class FilmMenuIterator implements Iterator2 {

    MenuItem[] menuItems;
    int position = 0;

    public FilmMenuIterator(MenuItem[] menuItems){
        this.menuItems = menuItems;
    }

    @Override
    public boolean hasNext() {
        if(position > menuItems.length-1 || menuItems[position] == null){
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        MenuItem menuItem = menuItems[position];
        position ++;
        return menuItem;
    }
}
